<?php echo $this->atheme->group_select2('view','Loại','','', 
	array(
		'mainmenu' => 'Main menu',
		'footmenu' => 'Foot menu',
		'home' => 'Danh sách game trang chủ',
		'parent' => 'Danh sách game trang danh mục',
	),@$config['view'],' id="cat-view"'); ?>
	
	<?php echo $this->atheme->group_input2('link', 'Đường dẫn url', '', 'span6 ', @$config['link'], 'text', ''); ?>
	<?php echo $this->atheme->group_input2('prefix', 'Tiền tố', '', 'span6 ', @$config['prefix'], 'text', ''); ?>
	<div data-type="mainmenu" style="display: block;">
		
	</div>
	
	
	<div data-type="home"  style="display: none;">
		<!-- Danh sách game trang chủ-->
	</div>
	<div data-type="parent"  style="display: none;">
		<!-- Danh sách game trang danh mục-->
		
	</div>
	<input type="hidden" name="cateid" id="cateid" value="<?php echo $config['cateid'] ?>" />
	<?php echo $this->atheme->group_select2('cateid_src','Danh mục','cateid_src','', $cat_tree,@explode(',',$config['cateid']),' multiple'); ?>
	<?php echo $this->atheme->group_input2('num', 'Số lượng game', '', 'span6 ', @$config['num'], 'text', ''); ?>

<script type="text/javascript">
$(function (){
	$('[name="view"]').change(function (){
		$('[data-type]').hide();
		$('[data-type="'+$(this).val()+'"]').show();
	});
	$('[name="view"]').change();
	
	$('#cateid_src').change(function (){
		var current_val = $('#cateid').val().split(',');
		var selected_val = $(this).val();
		$.each (selected_val, function (i, e) {
			if (current_val.indexOf(e + '') < 0) {
				current_val.push(e);
			}
		});
		//xoa cac phan tu ko dang chon;
		$.each (current_val, function (i, e) {
			if (selected_val.indexOf(e+'') < 0) {
				current_val.splice(i,1);
			}
		});
		$('#cateid').val(current_val.join(','))
	});
});

</script>